package com.company.goodfuture2020;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main3 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] rawData = br.readLine().split(" ");
        int len = rawData.length;
        int[] data = new int[len];
        for (int i = 0; i < len; i++) {
            data[i] = Integer.parseInt(rawData[i]);
        }
        int count = 1;
        int res = data[0];
        for (int i = 1; i < len; i++) {
            if(data[i] == res){
                count++;
            }else{
                count--;
                if(count == 0){
                    res = data[i];
                    count = 1;
                }
            }
        }
        System.out.println(res);
    }
}
